// 用户访问  localhost:8080/aaa 返回 index.html这个结果 
// http模块   
const { log } = require('console');
const http = require('http');
const fs = require('fs');
//搭建服务 
const server = http.createServer(function (req, res) {
    // console.log(req);
    if (req.url === '/aaa') {
        //读取文件 
        fs.readFile('C:\\www\\2302\\day32\\index.html', 'utf-8', (err, data) => {
            res.end(data);
        })
        // res.end('hello world aaa')
    }
    else {

        fs.readFile('C:\\www\\2302\\day32\\404.html', 'utf-8', (err, data) => res.end(data))
    }
})

// 启动服务

server.listen(8081, () => {
    console.log('服务开启,等待响应');
})